package com.qqla.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.qqla.dto.ExplorePageDto;
import com.qqla.entity.Explore;
import com.qqla.result.PageResult;
import com.qqla.result.ResponseResult;
import com.qqla.service.ExploreService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/user/explore")
@RequiredArgsConstructor
public class ExploreController {


    // 导入服务
    private final ExploreService exploreService;

    /*
    * 获取探索列表
    * */
    @PostMapping
    public ResponseResult list(@RequestBody ExplorePageDto dto) {
        Page<Explore> page = exploreService.lambdaQuery().page(new Page<>(dto.getPage(), dto.getPageSize()));
        PageResult result = PageResult.builder()
                .records(page.getRecords())
                .total(page.getTotal())
                .build();
        return ResponseResult.okResult(result);
    }
}
